<?php

/**
 * Created by PhpStorm.
 * User: fanfz_000
 * Date: 2015/5/1 0001
 * Time: 11:41
 * 作用 ：日志信息表
 */
class Systemblog_model extends CI_Model
{
    var $Id = '';
    var $text = '';
    var $date = '';

    /*显示按时间日志信息 2015-05-01*/
    function show_blog($begin_time, $end_time)
    {
        $data = $this->db->from('system_blog')->where('date <= ', $begin_time)->where('date >= ', $end_time)->get()->result_array();
        //echo $begin_time." ".$end_time." ".$this->db->last_query()."</br>";
        return $data;
    }

    function show_blog_list($page = 0, $limit = 10)
    {
        $data = $this->db->from('system_blog')->order_by('Id ASC')->limit($limit, $page * $limit)->get()->result_array();
        return array(
            'data' => $data,
            'total' => $this->db->count_all_results('system_blog'),
            'data_num' => count($data),
        );
    }

//删除日志i信息 2015-5-14
    function delete_system_blog($id)
    {
        $bool = $this->db->delete('system_blog', array('Id' => $id));
        if ($bool) {
            //删除成功
            return 1;
        } else {
            //数据异常
            $system_blog = array(
                'text' => '删除系统日志，记录失败。日志id为' . $id . ',sql:' . $this->db->last_query(),
                'date' => date('Y-m-d')
            );
            $this->db->insert('system_blog', $system_blog);
            return -1;
        }
    }
}